package com.lzy.algorithm;

import java.util.HashMap;
import java.util.Map;

public class 两数之和 {

    public static void main(String[] args) {
        boolean flag = false;
        int target = 11;
        int[] array = new int[]{5, 7, 3, 5, 8, 6, 9, 23, 6};
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < array.length; i++) {

            int last = target - array[i];
            if (map.containsKey(last)) {
                System.out.println(map.get(last) + "\t" + i);
                flag = true;
            } else {
                map.put(array[i], i);
            }
        }
        if (!flag) {
            System.out.println("没找到");
        }
    }
}
